import React from 'react';
import Route from 'react-router/lib/Route';
import {WeaLocaleProvider} from 'ecCom';

import Home from './components/Home';


import Center from './components/center';
import Add from './components/add/Add';
import ListDoing from './components/list/ListDoing';
import ListDone from './components/list/ListDone';
import ListMine from './components/list/ListMine';
import QueryIndex from './components/customQuery/QueryIndex';
import QueryResult from './components/customQuery/QueryResult';
import BatchPrintIndex from './components/batchPrint/PrintIndex';
import BatchPrintResult from './components/batchPrint/PrintResult';
import BatchToDocIndex from './components/batchToDoc/ToDocIndex';
import BatchToDocResult from './components/batchToDoc/ToDocResult';
import Agent from './components/agent/List';
import AddAgent from './components/agent/AddAgent';
import Monitor from './components/monitor/MonitorCondition';
import MonitorResult from './components/monitor/List';
import MonitorLog from './components/monitor/Log';
import Recycle from './components/list/Recycle';
import FreeflowTemplate from './components/freeflowTemplate/TemplateList';
// import Share from './components/share/List';
//报表分析
import CustomReportForm from './components/customReport/List';
import ViewCustomReport from './components/customReport/ViewReport';
import ViewCustomResult from './components/customReport/ViewReportResult';
import CustomReportChart from './components/customReport/Charts';
import CustomReportsAdd from './components/customReport/TempAddRukou';
//效率报表
import FlowTimeAnalyse from './components/efficiencyReport/flow-time-analyse/index';
import WfTypeAnalyse from './components/efficiencyReport/wf-type-analyse/index';
import WfDoingAnalyse from './components/efficiencyReport/wf-doing-analyse/index';
import HandleRequestAnalyse from './components/efficiencyReport/handle-request-analyse/index';
import MostOvertimeRequestAnalyse from './components/efficiencyReport/most-overtime-request-analyse/index';
import MostOvertimePersonAnalyse from './components/efficiencyReport/most-overtime-person-analyse/index';
import FlowHandleAnalyse from './components/efficiencyReport/flow-handle-analyse/index';
//标准自定义报表
import StandardCustomReportList from './components/stantardCustomReport/index';
import StandardCustomViewReport from './components/stantardCustomReport/ViewReport';
import StandardCustomViewReportResult from './components/stantardCustomReport/ViewReportResult';
import Supervise from './components/supervise/Supervise';
import SubWorkflowStatus from './components/list/SubWorkflowStatus';
//关注事宜
import Attention from './components/follow/index';
//表单智能分析
import Analyze from './components/reqAnalyze/AnalyzeAsync';

import './style/index';
import './util/listUtil.js';
import './util/reportUtil.js';
import './util/windowFun.js';
import './interface';
//流程扫描
import ScanWorkflow from './components/scanWorkflow'

import stores from './stores/index';

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'workflow');

const WorkflowRoute = (
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@yjz3rp`} name="workflow" breadcrumbName="流程" path="workflow" onEnter={getLocaleLabel} component={Home}>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@4n1ixp`} breadcrumbName='流程中心' path='center' component={Center}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@lyk3w3`} breadcrumbName="新建流程" path="add" component={Add}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@dv9054`} breadcrumbName="待办事宜" path="listDoing" component={ListDoing}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@htqpwn`} breadcrumbName="已办事宜" path="listDone" component={ListDone}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@wkrr40`} breadcrumbName="我的请求" path="listMine" component={ListMine}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@arc77i`} breadcrumbName="查询流程导航" path="queryFlow" component={QueryIndex}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zk0dk2`} breadcrumbName="查询流程结果" path="queryFlowResult" component={QueryResult}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@v5y7r1`} breadcrumbName="批量打印导航" path="batchPrint" component={BatchPrintIndex}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@n273vd`} breadcrumbName="批量打印结果" path="batchPrintResult" component={BatchPrintResult}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@b7cyac`} breadcrumbName="流程存为文档导航" path="batchToDoc" component={BatchToDocIndex}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@2gzxph`} breadcrumbName="流程存为文档结果" path="batchToDocResult" component={BatchToDocResult}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@wnzyk8`} breadcrumbName="流程代理" path="agent" component={Agent}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@g9s5dk`} breadcrumbName="新建代理" path="addAgent" component={AddAgent}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@rhf1fs`} breadcrumbName="流程监控" path="monitor" component={Monitor}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@pifjpy`} breadcrumbName="流程监控结果" path="monitorResult" component={MonitorResult}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@j8v4ep`} breadcrumbName="流程监控日志" path="monitorLog" component={MonitorLog}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@ytto4d`} breadcrumbName="流程回收站" path="recycle" component={Recycle}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@rr4361`} breadcrumbName="自由流程流转模板" path="freeflowTemplate" component={FreeflowTemplate}/>
        {/*<Route breadcrumbName="流程共享" path="share" component={Share}/>*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@uscjak`} breadcrumbName="流程督办" path="supervise" component={Supervise}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@t0qrob`} breadcrumbName="子流程查看状况" path="subWorkflowStatus" component={SubWorkflowStatus}/>
        {/*报表分析*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@sqr939`} name="customReportsAdd" breadcrumbName="自定义报表新建" path="customReportsAdd" component={CustomReportsAdd}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@hs334w`} name="customReportForm" breadcrumbName="报表分析" path="customReportForm" component={CustomReportForm}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@vcsl5h`} name="viewCustomReport" breadcrumbName="查看报表" path="viewCustomReport" component={ViewCustomReport}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@0kgete`} name="viewCustomResult" breadcrumbName="查看报表搜索结果" path="viewCustomResult" component={ViewCustomResult}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@3g0bvo`} name="customReportChart" breadcrumbName="生成图表" path="customReportChart" component={CustomReportChart}/>
        {/*效率报表*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@halir0`} name="flowTimeAnalyse" breadcrumbName="流程流转时间分析表" path="flowTimeAnalyse" component={FlowTimeAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qfsadd`} name="wfTypeAnalyse" breadcrumbName="流程类型统计表" path="wfTypeAnalyse" component={WfTypeAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@pvk6zi`} name="wfDoingAnalyse" breadcrumbName="待办事宜统计表" path="wfDoingAnalyse" component={WfDoingAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@b55wi7`} name="handleRequestAnalyse" breadcrumbName="人员办理时间分析表" path="handleRequestAnalyse" component={HandleRequestAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qwtxdu`} name="mostOvertimeRequestAnalyse" breadcrumbName="超期最多流程分析" path="mostOvertimeRequestAnalyse" component={MostOvertimeRequestAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@idxmum`} name="mostOvertimePersonAnalyse" breadcrumbName="超期最多人员分析" path="mostOvertimePersonAnalyse" component={MostOvertimePersonAnalyse}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@r81ejr`} name="flowHandleAnalyse" breadcrumbName="流程办理情况统计表" path="flowHandleAnalyse" component={FlowHandleAnalyse}/>
        {/*标准自定义报表*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@h9ilxx`} name="standardCustomReportList" breadcrumbName="自定义报表" path="standardCustomReportList" component={StandardCustomReportList}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@ox0x87`} name="standardCustomViewReport" breadcrumbName="自定义报表条件" path="standardCustomViewReport" component={StandardCustomViewReport}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qo8q45`} name="standardCustomViewReportResult" breadcrumbName="自定义报表查询结果" path="standardCustomViewReportResult" component={StandardCustomViewReportResult}/>
        {/*关注事宜*/}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@4eerth`} breadcrumbName="关注事宜" path="attention" component={Attention}/>
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@mpmee3`} breadcrumbName="流程扫描" path="scanWorkflow" component={ScanWorkflow}/>

        {/* 表单智能分析 */}
        <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@9dm18p`} breadcrumbName="智能分析" path="analyze" component={Analyze} />


    </Route>
)


export default function swapLocaleProvider(Component) {
    return class Main extends React.Component{
        constructor(props) {
            super(props);
            this.state = {
                reRender: false,
            };
        }
        componentDidMount() {
            WeaLocaleProvider.getLocaleLabelByCode('workflow').then(() => this.setState({ reRender: true }));
        }
        render(){
            const { reRender } = this.state;
            return <Component ecId={`${this && this.props && this.props.ecId || ''}_Component@k3m3r4`} {...this.props} />
        }
    }
}

module.exports = {
    Route: WorkflowRoute,
    store: stores,
    // publicComps: {
    //     Share: swapLocaleProvider(Share)
    // }
}

/***** window方法与store通信统一规范 *****/
const doWorkflowAction = {
    refreshDoingList: function () {
        stores.wfListDoingStore.reLoad();
    }
}

window.doWorkflowAction = doWorkflowAction;
